
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>JavaScript的优雅写法 · 记录技术文档内容</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="zhengyuliang">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-sectionx/sectionx.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-splitter/splitter.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-tbfed-pagefooter/footer.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-plus/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-donate/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-anchor-navigation-ex/style/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="axios知识点.html" />
    
    
    <link rel="prev" href="JavaScript数组求并集，交集和差集.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        <li class="header">CSS</li>
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../CSS/18种CSS命名和书写规范.html">
            
                <a href="../CSS/18种CSS命名和书写规范.html">
            
                    
                    18种CSS命名和书写规范
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../CSS/灵活运用CSS开发技巧.html">
            
                <a href="../CSS/灵活运用CSS开发技巧.html">
            
                    
                    灵活运用CSS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../CSS/自适应 flex grid.html">
            
                <a href="../CSS/自适应 flex grid.html">
            
                    
                    自适应 Flex Grid
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">HTML</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                <a href="../HTML/浏览器里的本地数据库：IndexedDB.html">
            
                    
                    浏览器里的本地数据库：IndexedDB
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Vue</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../Vue/7个有用的Vue开发技巧.html">
            
                <a href="../Vue/7个有用的Vue开发技巧.html">
            
                    
                    7个有用的Vue开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                <a href="../Vue/Vue this.$router.push、replace、go的区别.html">
            
                    
                    Vue This.$Router.Push、Replace、Go的区别
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                <a href="../Vue/Vue 的父组件和子组件生命周期钩子函数执行顺序？.html">
            
                    
                    Vue 的父组件和子组件生命周期钩子函数执行顺序？
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../Vue/Vue.set和this.$set应用的场景.html">
            
                <a href="../Vue/Vue.set和this.$set应用的场景.html">
            
                    
                    Vue.Set和This.$Set应用的场景
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../Vue/vue高级技巧.html">
            
                <a href="../Vue/vue高级技巧.html">
            
                    
                    Vue高级技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                <a href="../Vue/从 0 开始手把手带你搭建一套规范的 Vue3.x 项目工程环境.html">
            
                    
                    从 0 开始手把手带你搭建一套规范的 Vue3.X 项目工程环境
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                <a href="../Vue/浅析 vue-router 源码和动态路由权限分配.html">
            
                    
                    浅析 Vue Router 源码和动态路由权限分配
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../Vue/父组件监听到子组件的生命周期.html">
            
                <a href="../Vue/父组件监听到子组件的生命周期.html">
            
                    
                    父组件监听到子组件的生命周期
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                <a href="../Vue/理解Vue.mixin，利用Vue.mixin正确的偷懒.html">
            
                    
                    理解Vue.Mixin，利用Vue.Mixin正确的偷懒
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">JavaScript</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="5个技巧让你更好的编写 JavaScript(ES6">
            
                <span>
            
                    
                    5个技巧让你更好的编写 JavaScript(ES6) 中条件语句
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="5种常见函数的写法和调用方式.html">
            
                <a href="5种常见函数的写法和调用方式.html">
            
                    
                    5种常见函数的写法和调用方式
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="7道javascript题，让你理解基本的javascript.html">
            
                <a href="7道javascript题，让你理解基本的javascript.html">
            
                    
                    7道Javascript题，让你理解基本的Javascript
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="Array.from(">
            
                <span>
            
                    
                    Array.From() 五个超好用的用途
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="ES6汇总资料.html">
            
                <a href="ES6汇总资料.html">
            
                    
                    ES6汇总资料
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="JS开发必须知道的41个技巧.html">
            
                <a href="JS开发必须知道的41个技巧.html">
            
                    
                    JS开发必须知道的41个技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="JavaScript之防抖Debounce和节流Throttle.html">
            
                <a href="JavaScript之防抖Debounce和节流Throttle.html">
            
                    
                    JavaScript之防抖Debounce和节流Throttle
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="JavaScript数组求并集，交集和差集.html">
            
                <a href="JavaScript数组求并集，交集和差集.html">
            
                    
                    JavaScript数组求并集，交集和差集
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="4.9" data-path="JavaScript的优雅写法.html">
            
                <a href="JavaScript的优雅写法.html">
            
                    
                    JavaScript的优雅写法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.10" data-path="axios知识点.html">
            
                <a href="axios知识点.html">
            
                    
                    Axios知识点
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.11" data-path="javascript核心知识.html">
            
                <a href="javascript核心知识.html">
            
                    
                    Javascript核心知识
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.12" data-path="this、apply、call、bind.html">
            
                <a href="this、apply、call、bind.html">
            
                    
                    This、Apply、Call、Bind
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.13" data-path="前端js常用的60余种工具方法.html">
            
                <a href="前端js常用的60余种工具方法.html">
            
                    
                    前端Js常用的60余种工具方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.14" data-path="前端异常的捕获与处理.html">
            
                <a href="前端异常的捕获与处理.html">
            
                    
                    前端异常的捕获与处理
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.15" data-path="在 JavaScript 中交换值的 10 种方法.html">
            
                <a href="在 JavaScript 中交换值的 10 种方法.html">
            
                    
                    在 JavaScript 中交换值的 10 种方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.16" data-path="常用的前端JavaScript方法封装.html">
            
                <a href="常用的前端JavaScript方法封装.html">
            
                    
                    常用的前端JavaScript方法封装
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.17" data-path="异步神器Async-await介绍与填坑.html">
            
                <a href="异步神器Async-await介绍与填坑.html">
            
                    
                    异步神器Async Await介绍与填坑
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.18" data-path="灵活运用JS开发技巧.html">
            
                <a href="灵活运用JS开发技巧.html">
            
                    
                    灵活运用JS开发技巧
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.19" data-path="编写高质量可维护的代码：一目了然的注释.html">
            
                <a href="编写高质量可维护的代码：一目了然的注释.html">
            
                    
                    编写高质量可维护的代码：一目了然的注释
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.20" data-path="编写高质量可维护的代码：优化逻辑判断.html">
            
                <a href="编写高质量可维护的代码：优化逻辑判断.html">
            
                    
                    编写高质量可维护的代码：优化逻辑判断
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.21" data-path="编写高质量可维护的代码：优雅命名.html">
            
                <a href="编写高质量可维护的代码：优雅命名.html">
            
                    
                    编写高质量可维护的代码：优雅命名
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.22" data-path="编写高质量可维护的代码：数据建模.html">
            
                <a href="编写高质量可维护的代码：数据建模.html">
            
                    
                    编写高质量可维护的代码：数据建模
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Life Exp</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../life_exp/告别平庸的15个小方法.html">
            
                <a href="../life_exp/告别平庸的15个小方法.html">
            
                    
                    告别平庸的15个小方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../life_exp/日志记录.html">
            
                <a href="../life_exp/日志记录.html">
            
                    
                    日志记录
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../life_exp/程序员的发展方向.html">
            
                <a href="../life_exp/程序员的发展方向.html">
            
                    
                    程序员的发展方向
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../message/">
            
                <a href="../message/">
            
                    
                    Message
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Technology</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../technology/WebSocket.html">
            
                <a href="../technology/WebSocket.html">
            
                    
                    WebSocket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../technology/npm常用命令大全.html">
            
                <a href="../technology/npm常用命令大全.html">
            
                    
                    Npm常用命令大全
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../technology/智能照明项目说明.html">
            
                <a href="../technology/智能照明项目说明.html">
            
                    
                    智能照明项目说明
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../technology/规范化git的提交信息.html">
            
                <a href="../technology/规范化git的提交信息.html">
            
                    
                    规范化Git的提交信息
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Tutorial</li>
        
        
    
        <li class="chapter " data-level="7.1" data-path="../tutorial/Esmap地图详解.html">
            
                <a href="../tutorial/Esmap地图详解.html">
            
                    
                    Esmap地图详解
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="../tutorial/npm镜像切换.html">
            
                <a href="../tutorial/npm镜像切换.html">
            
                    
                    Npm镜像切换
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="../tutorial/发布npm的教程.html">
            
                <a href="../tutorial/发布npm的教程.html">
            
                    
                    发布Npm的教程
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >JavaScript的优雅写法</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div class="search-plus" id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <html><head></head><body><div id="anchor-navigation-ex-navbar"><i class="fa fa-navicon"></i><ul><ul><ul><li><span class="title-icon "></span><a href="#&#x63A2;&#x8BA8;javascript&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;"><b>1.1.1. </b>&#x63A2;&#x8BA8;JavaScript&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;</a></li><li><span class="title-icon "></span><a href="#javascript-&#x590D;&#x6742;&#x5224;&#x65AD;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;"><b>1.1.2. </b>JavaScript &#x590D;&#x6742;&#x5224;&#x65AD;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;</a></li></ul></ul></ul></div><a href="#" id="anchorNavigationExGoTop"><i class="fa fa-arrow-up"></i></a><h3 id="&#x63A2;&#x8BA8;javascript&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;"><a name="&#x63A2;&#x8BA8;javascript&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#&#x63A2;&#x8BA8;javascript&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.1. &#x63A2;&#x8BA8;JavaScript&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;</h3>
<blockquote>
<p> &#x7528;&#x6700;&#x5408;&#x9002;&#x7684;&#x4EE3;&#x7801;&#x6267;&#x884C;&#x6B63;&#x786E;&#x7684;&#x903B;&#x8F91;&#xFF0C; &#x53E5;&#x8BDD;&#x610F;&#x601D;&#x662F;&#x8BF4;&#xFF0C;&#x6BCF;&#x4E00;&#x884C;&#x4EE3;&#x7801;&#x8981;&#x505A;&#x5230;&#x7B80;&#x6D01;&#xFF0C;&#x5BB9;&#x6613;&#x7406;&#x89E3; </p>
</blockquote>
<p>&#x300C;&#x4F18;&#x96C5;&#x300D;&#x6700;&#x76F4;&#x89C2;&#x7684;&#x8868;&#x73B0;&#x5C31;&#x662F;<strong>&#x770B;&#x8D77;&#x6765;&#x8212;&#x670D;</strong>&#xFF0C;&#x8981;&#x505A;&#x5230;&#x8FD9;&#x4E00;&#x70B9;&#x4E0D;&#x96BE;&#xFF0C;&#x90A3;&#x5C31;&#x662F;&#x4EE3;&#x7801;&#x4E66;&#x5199;&#x8BB2;&#x7A76;&#x4E00;&#x4E2A;&#x89C4;&#x8303;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;&#x4F60;&#x6700;&#x4E60;&#x60EF;&#x7684;&#x6362;&#x884C;&#xFF0C;&#x6700;&#x4E60;&#x60EF;&#x7684;&#x53D8;&#x91CF;&#x547D;&#x540D;&#x7B49;&#x7B49;&#x3002;&#x4E0D;&#x8981;&#x4E00;&#x4E2A;&#x51E0;&#x767E;&#x884C;&#x4EE3;&#x7801;&#xFF0C;&#x4E66;&#x5199;&#x4E60;&#x60EF;&#x6362;&#x4E86;&#x597D;&#x51E0;&#x6B21;&#x3002;&#x505A;&#x5230;&#x8FD9;&#x4E00;&#x70B9;&#xFF0C;&#x90A3;&#x4E48;&#x81EA;&#x5DF1;&#x770B;&#x8D77;&#x6765;&#x5C31;&#x80FD;&#x8212;&#x670D;&#x4E86;&#x3002;&#x4F46;&#x662F;&#x8FD9;&#x4EC5;&#x4EC5;&#x662F;&#x6700;&#x57FA;&#x672C;&#x7684;&#xFF0C;&#x516C;&#x53F8;&#x4E2D;&#x7684;&#x9879;&#x76EE;&#x5F80;&#x5F80;&#x662F;&#x4E0D;&#x6B62;&#x4E00;&#x4E2A;&#x4EBA;&#x5F00;&#x53D1;&#xFF0C;&#x66F4;&#x591A;&#x7684;&#x662F;&#x534F;&#x540C;&#x5F00;&#x53D1;&#x3002;&#x4EE3;&#x7801;&#x4EC5;&#x4EC5;&#x662F;&#x81EA;&#x5DF1;&#x770B;&#x8D77;&#x6765;&#x8212;&#x670D;&#x8FD8;&#x4E0D;&#x884C;&#xFF0C;&#x8FD8;&#x8981;&#x505A;&#x5230;&#x5176;&#x4ED6;&#x4EBA;<strong>&#x770B;&#x8D77;&#x6765;&#x4E5F;&#x8212;&#x670D;</strong>&#x3002;&#x8981;&#x505A;&#x5230;&#x8FD9;&#x4E00;&#x70B9;&#xFF0C;&#x5C31;&#x9700;&#x8981;<strong>&#x628A;&#x6BCF;&#x4E2A;&#x4EBA;&#x4E66;&#x5199;&#x7684;&#x4E60;&#x60EF;&#x7EDF;&#x4E00;&#x8D77;&#x6765;&#xFF0C;&#x5F62;&#x6210;&#x56E2;&#x961F;&#x89C4;&#x8303;</strong>&#x3002;</p>
<blockquote>
<p>&#x4E3A;&#x4E86;&#x66F4;&#x597D;&#x7684;&#x5199;&#x4EE3;&#x7801;&#xFF0C;&#x63D0;&#x5347;&#x81EA;&#x5DF1;&#xFF0C;&#x6211;&#x5FCD;&#x4E86;&#x3002;&#x770B;&#x7684;&#x6587;&#x7AE0;&#x8D8A;&#x591A;&#xFF0C;&#x53D1;&#x73B0;&#x81EA;&#x5DF1;&#x61C2;&#x7684;&#x8D8A;&#x5C11;&#x3002;&#x5509;&#xFF0C;&#x4E3A;&#x4EC0;&#x4E48;&#xFF1F;&#x6C42;&#x89E3;&#xFF01;</p>
<p>&#x4F18;&#x96C5;&#x5199;&#x6CD5;&#xFF0C;&#x4EE5;&#x524D;&#x5BF9;&#x4E8E;&#x6211;&#x6765;&#x8BF4;&#x662F;&#x6CA1;&#x6709;&#x770B;&#x56DE;&#x4E8B;&#x7684;&#x3002;&#x5199;&#x4EE3;&#x7801;&#x5C31;&#x662F;&#x628A;&#x6574;&#x4E2A;&#x6A21;&#x5757;&#x5207;&#x5206;&#x4E3A;&#x4E0D;&#x540C;&#x7684;&#x6A21;&#x5757;&#xFF0C;&#x8BA9;&#x6BCF;&#x4E2A;&#x6A21;&#x5757;&#x66F4;&#x597D;&#x7684;&#x5DE5;&#x4F5C;&#xFF0C;&#x5E76;&#x7EDF;&#x4E00;&#x8D77;&#x6765;&#x3002;&#x770B;&#x5230;&#x8FD9;&#x6587;&#x7AE0;&#xFF0C;&#x4E5F;&#x5B66;&#x5B66;&#x3002;</p>
</blockquote>
<p> <strong>&#x5224;&#x65AD;&#x5BF9;&#x5185;&#x7684;&#x300C;&#x4F18;&#x96C5;&#x300D;&#x5F88;&#x7B80;&#x5355;&#xFF0C;&#x81EA;&#x5DF1;&#x770B;&#x4EE3;&#x7801;&#x80FD;&#x591F;&#x6BEB;&#x4E0D;&#x8D39;&#x52B2;&#x5C31;&#x80FD;&#x7406;&#x89E3;&#x903B;&#x8F91;&#xFF0C;&#x5E76;&#x4E14;&#x6CA1;&#x6709;&#x300C;&#x4E71;&#x7CDF;&#x7CDF;&#x300D;&#xFF0C;&#x300C;&#x591A;&#x4F59;&#x300D;&#x7684;&#x611F;&#x89C9;&#x3002;</strong> </p>
<h4 id="&#x5177;&#x4F53;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;&#x5B9E;&#x4F8B;"><a name="&#x5177;&#x4F53;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;&#x5B9E;&#x4F8B;" class="anchor-navigation-ex-anchor" href="#&#x5177;&#x4F53;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;&#x5B9E;&#x4F8B;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x5177;&#x4F53;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;&#x5B9E;&#x4F8B;</h4>
<ol>
<li><p>&#x8FD0;&#x7B97;&#x7B26;&#x5904;&#x6362;&#x884C;&#x65F6;&#xFF0C;&#x8FD0;&#x7B97;&#x7B26;&#x5728;&#x65B0;&#x884C;&#x7684;&#x884C;&#x9996;&#x3002;
&#x5728;&#x8FDB;&#x884C;&#x590D;&#x6742;&#x7684;&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x65F6;&#xFF0C;&#x6211;&#x4EEC;&#x4F1A;&#x4F7F;&#x7528;&#x5230;&amp;&amp;&#x4E0E;||&#xFF0C;&#x8FD9;&#x4E2A;&#x4F7F;&#x7528;&#x8FC7;&#x957F;&#x7684;&#x5224;&#x65AD;&#x6761;&#x4EF6;&#x5F88;&#x5BB9;&#x6613;&#x8BA9;&#x4EBA;&#x5FC3;&#x751F;&#x538C;&#x6076;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#x4EE5;&#x4E00;&#x79CD;&#x6F02;&#x4EAE;&#x7684;&#x4E66;&#x5199;&#x98CE;&#x683C;&#x4F1A;&#x66F4;&#x4EBA;&#x8BA9;&#x6211;&#x4EEC;&#x63A5;&#x53D7;&#x3002; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// good</span>
<span class="hljs-keyword">if</span> (user.isAuthenticated()
    &amp;&amp; user.isInRole(<span class="hljs-string">&apos;admin&apos;</span>)
    &amp;&amp; user.hasAuthority(<span class="hljs-string">&apos;add-admin&apos;</span>)
    || user.hasAuthority(<span class="hljs-string">&apos;delete-admin&apos;</span>)
) {
    <span class="hljs-comment">// Code</span>
}
<span class="hljs-keyword">var</span> result = number1 + number2 + number3
    + number4 + number5;

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">if</span> (user.isAuthenticated() &amp;&amp;
    user.isInRole(<span class="hljs-string">&apos;admin&apos;</span>) &amp;&amp;
    user.hasAuthority(<span class="hljs-string">&apos;add-admin&apos;</span>) ||
    user.hasAuthority(<span class="hljs-string">&apos;delete-admin&apos;</span>)) {
    <span class="hljs-comment">// Code</span>
}

<span class="hljs-keyword">var</span> result = number1 + number2 + number3 +
    number4 + number5;
</code></pre>
</li>
</ol>
<ol>
<li><p>boolean &#x7C7B;&#x578B;&#x7684;&#x53D8;&#x91CF;&#x4F7F;&#x7528; is &#x6216; has &#x5F00;&#x5934;
&#x8FD9;&#x6837;&#x505A;&#x7684;&#x597D;&#x5904;&#x662F;&#x80FD;&#x4E00;&#x773C;&#x770B;&#x51FA;&#x8BE5;&#x53D8;&#x91CF;&#x5C31;&#x662F;&#x4E00;&#x4E2A;&#x5E03;&#x5C14;&#x53D8;&#x91CF;&#x3002; </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> isReady = <span class="hljs-literal">false</span>;
<span class="hljs-keyword">var</span> hasMoreCommands = <span class="hljs-literal">false</span>;
</code></pre>
</li>
<li><p>&#x5C3D;&#x53EF;&#x80FD;&#x4F7F;&#x7528;&#x7B80;&#x6D01;&#x8868;&#x8FBE;&#x5F0F; </p>
<p>&#x5728;&#x8BB2;&#x8FD9;&#x4E2A;&#x4E4B;&#x524D;&#xFF0C;&#x5148;&#x6765;&#x590D;&#x4E60;&#x4E00;&#x4E0B;JS&#x4E2D;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x53CA;&#x5224;&#x65AD;&#x65B9;&#x5F0F;&#x3002; </p>
<p><img src="https://github.com/zhengyuliang/Blog-Back-Up/blob/master/images/javascript/javascript_01.png?raw=true" alt="javascript"></p>
<p>&#x5982;&#x4E0A;&#x56FE;&#x6240;&#x793A;&#xFF0C;JS&#x4E2D;&#x7684;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x5206;&#x4E3A;<strong>&#x57FA;&#x672C;&#x6570;&#x636E;&#x7C7B;&#x578B;</strong>&#x548C;<strong>&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;</strong>&#xFF0C;<strong>&#x5F15;&#x7528;&#x6570;&#x636E;&#x7C7B;&#x578B;</strong>&#x4E00;&#x822C;&#x4E5F;&#x88AB;&#x76F4;&#x63A5;&#x53EB;&#x505A;<strong>&#x5BF9;&#x8C61;</strong>&#x3002;&#x5BF9;&#x8C61;&#x53EF;&#x4EE5;&#x770B;&#x505A;&#x662F;&#x4E00;&#x4E2A;&#x590D;&#x5408;&#x6570;&#x636E;&#x7C7B;&#x578B;&#xFF0C;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x7528;&#x5B83;&#x6765;&#x7EC4;&#x88C5;&#x5176;&#x4ED6;&#x6570;&#x636E;&#x7C7B;&#x578B;&#x3002;&#x5176;&#x4E2D;&#x88AB;&#x5B98;&#x65B9;&#x7EC4;&#x88C5;&#x597D;&#x7684;&#x4E5F;&#x662F;&#x7528;&#x7684;&#x5F88;&#x5E7F;&#x6CDB;&#x7684;&#x4E3B;&#x8981;&#x662F;&#x56DB;&#x79CD;&#xFF1A;<strong>Array(&#x6570;&#x7EC4;)</strong>&#xFF0C;<strong>Function(&#x51FD;&#x6570;)</strong>&#xFF0C;<strong>RegExp(&#x6B63;&#x5219;)</strong>&#x548C;<strong>Date(&#x65E5;&#x671F;)</strong>&#x3002;</p>
<p><img src="https://github.com/zhengyuliang/Blog-Back-Up/blob/master/images/javascript/javascript_02.png?raw=true" alt="&#x7C7B;&#x578B;&#x5224;&#x65AD;"></p>
<p>&#x90A3;&#x4E48;&#x5728;&#x4F7F;&#x7528; if else&#x65F6;&#xFF0C;&#x5BF9;&#x4E8E;&#x6761;&#x4EF6;&#x7684;&#x5224;&#x65AD;&#xFF0C;<strong>&#x6211;&#x4EEC;&#x5C3D;&#x53EF;&#x80FD;&#x4F7F;&#x7528;&#x7B80;&#x6D01;&#x8868;&#x8FBE;&#x5F0F;</strong>&#xFF1A; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x5B57;&#x7B26;&#x4E32;&#x4E3A;&#x7A7A;</span>
<span class="hljs-comment">// good</span>
<span class="hljs-keyword">if</span> (!name) {
   <span class="hljs-comment">// ......</span>
}
<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">if</span> (name === <span class="hljs-string">&apos;&apos;</span>) {
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// &#x5B57;&#x7B26;&#x4E32;&#x975E;&#x7A7A;</span>
<span class="hljs-comment">// good</span>
<span class="hljs-keyword">if</span> (name) {
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">if</span> (name !== <span class="hljs-string">&apos;&apos;</span>) {
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// &#x6570;&#x7EC4;&#x975E;&#x7A7A;</span>
<span class="hljs-comment">// good</span>
<span class="hljs-keyword">if</span> (collection.length) {
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">if</span> (collection.length &gt; <span class="hljs-number">0</span>) {
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// &#x5E03;&#x5C14;&#x4E0D;&#x6210;&#x7ACB;</span>
<span class="hljs-comment">// good</span>
<span class="hljs-keyword">if</span> (!notTrue) {
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">if</span> (notTrue === <span class="hljs-literal">false</span>) {
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// null &#x6216; undefined</span>
<span class="hljs-comment">// good</span>
<span class="hljs-keyword">if</span> (noValue == <span class="hljs-literal">null</span>) {
 <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">if</span> (noValue === <span class="hljs-literal">null</span> || <span class="hljs-keyword">typeof</span> noValue === <span class="hljs-string">&apos;undefined&apos;</span>) {
 <span class="hljs-comment">// ......</span>
}
</code></pre>
</li>
<li><p>&#x5982;&#x679C;&#x51FD;&#x6570;&#x6216;&#x5168;&#x5C40;&#x4E2D;&#x7684; else &#x5757;&#x540E;&#x6CA1;&#x6709;&#x4EFB;&#x4F55;&#x8BED;&#x53E5;&#xFF0C;&#x53EF;&#x4EE5;<strong>&#x5220;&#x9664; else</strong>&#x3002; </p>
<blockquote>
<p>&#x8FD9;&#x4E2A;&#x7528;&#x7684;&#x591A;&#xFF0C;&#x4E0D;&#x7528;&#x8BF4;&#xFF0C;&#x4E86;&#x89E3;</p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getName</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">if</span> (name) {
      <span class="hljs-keyword">return</span> name;
  }

  <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;unnamed&apos;</span>;
}

<span class="hljs-comment">// bad</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getName</span>(<span class="hljs-params"></span>) </span>{
  <span class="hljs-keyword">if</span> (name) {
      <span class="hljs-keyword">return</span> name;
  }
  <span class="hljs-keyword">else</span> {
      <span class="hljs-keyword">return</span> <span class="hljs-string">&apos;unnamed&apos;</span>;
  }
}
</code></pre>
</li>
<li><p>&#x4E0D;&#x8981;&#x5728;&#x5FAA;&#x73AF;&#x4F53;&#x4E2D;&#x5305;&#x542B;&#x51FD;&#x6570;&#x8868;&#x8FBE;&#x5F0F;&#xFF0C;&#x4E8B;&#x5148;&#x5C06;&#x51FD;&#x6570;&#x63D0;&#x53D6;&#x5230;&#x5FAA;&#x73AF;&#x4F53;&#x5916; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// good</span>
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">clicker</span>(<span class="hljs-params"></span>) </span>{
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, len = elements.length; i &lt; len; i++) {
   <span class="hljs-keyword">var</span> element = elements[i];
   addListener(element, <span class="hljs-string">&apos;click&apos;</span>, clicker);
}

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, len = elements.length; i &lt; len; i++) {
   <span class="hljs-keyword">var</span> element = elements[i];
   addListener(element, <span class="hljs-string">&apos;click&apos;</span>, <span class="hljs-function"><span class="hljs-keyword">function</span> (<span class="hljs-params"></span>) </span>{});
}
</code></pre>
</li>
<li><p>&#x5BF9;&#x5FAA;&#x73AF;&#x5185;&#x591A;&#x6B21;&#x4F7F;&#x7528;&#x7684;&#x4E0D;&#x53D8;&#x503C;&#xFF0C;&#x5728;&#x5FAA;&#x73AF;&#x5916;&#x7528;&#x53D8;&#x91CF;&#x7F13;&#x5B58; </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// good</span>
<span class="hljs-keyword">var</span> width = wrap.offsetWidth + <span class="hljs-string">&apos;px&apos;</span>;
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, len = elements.length; i &lt; len; i++) {
   <span class="hljs-keyword">var</span> element = elements[i];
   element.style.width = width;
   <span class="hljs-comment">// ......</span>
}

<span class="hljs-comment">// bad</span>
<span class="hljs-keyword">for</span> (<span class="hljs-keyword">var</span> i = <span class="hljs-number">0</span>, len = elements.length; i &lt; len; i++) {
   <span class="hljs-keyword">var</span> element = elements[i];
   element.style.width = wrap.offsetWidth + <span class="hljs-string">&apos;px&apos;</span>;
   <span class="hljs-comment">// ......</span>
}
</code></pre>
</li>
<li><p>&#x5BF9;&#x6709;&#x5E8F;&#x96C6;&#x5408;&#x8FDB;&#x884C;&#x987A;&#x5E8F;&#x65E0;&#x5173;&#x7684;&#x904D;&#x5386;&#x65F6;&#xFF0C;&#x4F7F;&#x7528;&#x9006;&#x5E8F;&#x904D;&#x5386; </p>
<blockquote>
<p> &#x89E3;&#x91CA;:&#x9006;&#x5E8F;&#x904D;&#x5386;&#x53EF;&#x4EE5;&#x8282;&#x7701;&#x53D8;&#x91CF;&#xFF0C;&#x4EE3;&#x7801;&#x6BD4;&#x8F83;&#x4F18;&#x5316;&#x3002; </p>
</blockquote>
<pre><code class="lang-javascript"> <span class="hljs-keyword">var</span> len = elements.length;
 <span class="hljs-keyword">while</span> (len--) {
     <span class="hljs-keyword">var</span> element = elements[len];
     <span class="hljs-comment">// ......</span>
     }
</code></pre>
</li>
<li><p>&#x7C7B;&#x578B;&#x68C0;&#x6D4B;&#x4F18;&#x5148;&#x4F7F;&#x7528; <strong>typeof</strong>&#x3002;&#x5BF9;&#x8C61;&#x7C7B;&#x578B;&#x68C0;&#x6D4B;&#x4F7F;&#x7528; <strong>instanceof</strong>&#x3002;<strong>null</strong> &#x6216; <strong>undefined</strong> &#x7684;&#x68C0; &#x6D4B;&#x4F7F;&#x7528; == null </p>
</li>
<li><p>&#x8F6C;&#x6362;&#x6210; number &#x65F6;&#xFF0C;&#x901A;&#x5E38;&#x4F7F;&#x7528;+ </p>
<pre><code class="lang-javascript"><span class="hljs-comment">// good </span>
+str;

<span class="hljs-comment">//bad </span>
<span class="hljs-built_in">Number</span>(str);
</code></pre>
</li>
<li><p>&#x8F6C;&#x6362;&#x6210; <strong>boolean</strong> &#x65F6;&#xFF0C;&#x4F7F;&#x7528;!! </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">var</span> num = <span class="hljs-number">3.14</span>;
!!num;
</code></pre>
</li>
<li><p>&#x5C5E;&#x6027;&#x8BBF;&#x95EE;&#x5C3D;&#x91CF;&#x4F7F;&#x7528;&#x70B9;&#x8BED;&#x6CD5; </p>
<blockquote>
<p> &#x89E3;&#x91CA;:&#x5982;&#x975E;&#x5FC5;&#x987B;&#x4F7F;&#x7528;[]&#x7684;&#x60C5;&#x51B5;&#xFF0C;&#x5219;&#x5EFA;&#x8BAE;&#x4F18;&#x5148;&#x4F7F;&#x7528;&#x70B9;&#x8BED;&#x6CD5;&#x3002;&#x901A;&#x5E38;&#x5728; JavaScript &#x4E2D;&#x58F0;&#x660E;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x5C5E;&#x6027;
&#x547D;&#x540D;&#x662F;&#x4F7F;&#x7528; Camel &#x547D;&#x540D;&#x6CD5;&#xFF0C;&#x7528; . &#x6765;&#x8BBF;&#x95EE;&#x66F4;&#x6E05;&#x6670;&#x7B80;&#x6D01;&#x3002; </p>
</blockquote>
<pre><code class="lang-javascript">info.age;
info[<span class="hljs-string">&apos;more-info&apos;</span>];
</code></pre>
</li>
<li><p>&#x6E05;&#x7A7A;&#x6570;&#x7EC4;&#x4F7F;&#x7528; .length=0 </p>
</li>
<li><p>&#x4F7F;&#x7528; let &#x548C; const &#x5B9A;&#x4E49;&#x53D8;&#x91CF;&#xFF0C;&#x5C3D;&#x91CF;&#x4E0D;&#x4F7F;&#x7528; <strong>var</strong> </p>
<blockquote>
<p> &#x89E3;&#x91CA;:&#x4F7F;&#x7528; <strong>let</strong> &#x548C; <strong>const</strong> &#x5B9A;&#x4E49;&#x65F6;&#xFF0C;&#x53D8;&#x91CF;&#x4F5C;&#x7528;&#x57DF;&#x8303;&#x56F4;&#x66F4;&#x660E;&#x786E;&#x3002; </p>
</blockquote>
</li>
<li><p>&#x4F7F;&#x7528; Object.keys &#x6216; Object.entries &#x8FDB;&#x884C;&#x5BF9;&#x8C61;&#x904D;&#x5386; </p>
<blockquote>
<p> &#x89E3;&#x91CA;:&#x4E0D;&#x5EFA;&#x8BAE;&#x4F7F;&#x7528; for .. in &#x8FDB;&#x884C;&#x5BF9;&#x8C61;&#x7684;&#x904D;&#x5386;&#xFF0C;&#x4EE5;&#x907F;&#x514D;&#x9057;&#x6F0F; hasOwnProperty &#x4EA7;&#x751F;&#x7684;&#x9519;&#x8BEF;&#x3002; </p>
</blockquote>
</li>
<li><p>&#x4F7F;&#x7528;&amp;&amp;&#x6216;||&#x4EE3;&#x66FF;&#x4E09;&#x5143;&#x8868;&#x8FBE;&#x5F0F; </p>
<blockquote>
<p> &#x903B;&#x8F91;&#x4E0E;&#x8FD0;&#x7B97;&#x548C;&#x903B;&#x8F91;&#x6216;&#x8FD0;&#x7B97;&#xFF0C;&#x5B9E;&#x9645;&#x4E0A;&#x53EF;&#x4EE5;&#x770B;&#x505A;&#x662F;&#x6761;&#x4EF6;&#x8FD0;&#x7B97;&#x7684;&#x8BED;&#x6CD5;&#x7CD6;&#x3002;&#x540C;&#x65F6;JS
&#x4E2D;&#x7684;&#x4E09;&#x5143;&#x8FD0;&#x7B97;&#x7B26;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x770B;&#x505A;&#x662F;&#x6761;&#x4EF6;&#x8FD0;&#x7B97;&#x7684;&#x7B80;&#x5199;&#x65B9;&#x5F0F;&#x3002;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x4F7F;&#x7528;&amp;&amp;&#x548C;||&#x66FF;&#x4EE3;&#xFF0C;&#x8FD9;&#x6837;&#x51CF;&#x5C11;&#x4E86;&#x4EE3;&#x7801;&#x91CF;&#xFF0C;&#x8FD8;&#x4FBF;&#x4E8E;&#x7406;&#x89E3;&#x3002; </p>
</blockquote>
<pre><code class="lang-javascript"><span class="hljs-comment">// &#x4E0D;&#x63A8;&#x8350;</span>
<span class="hljs-keyword">let</span> userName = localStorage.userName ? localStorage.userName : <span class="hljs-string">&apos;admin&apos;</span>
<span class="hljs-comment">// &#x63A8;&#x8350;</span>
<span class="hljs-keyword">let</span> userName = localStorage.userName || <span class="hljs-string">&apos;admin&apos;</span>
</code></pre>
</li>
</ol>
<h3 id="javascript-&#x590D;&#x6742;&#x5224;&#x65AD;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;"><a name="javascript-&#x590D;&#x6742;&#x5224;&#x65AD;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#javascript-&#x590D;&#x6742;&#x5224;&#x65AD;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a>1.1.2. JavaScript &#x590D;&#x6742;&#x5224;&#x65AD;&#x7684;&#x4F18;&#x96C5;&#x5199;&#x6CD5;</h3>
<blockquote>
<p>&#x524D;&#x8A00;: &#x4E4B;&#x524D;&#x9879;&#x76EE;&#x4E2D;&#x770B;&#x5230;&#x5F88;&#x591A;&#x4EBA;&#x4EE3;&#x7801;&#x91CC;&#x7528;&#x4E86;&#x5F88;&#x591A;if-else&#x8BED;&#x6CD5;&#xFF0C;&#x751A;&#x81F3;&#x8FBE;&#x5230;&#x4E86;&#x75F4;&#x8FF7;&#x7684;&#x5730;&#x6B65;&#xFF0C;&#x5927;&#x5927;&#x5F71;&#x54CD;&#x4E86;&#x4EE3;&#x7801;&#x7684;&#x53EF;&#x8BFB;&#x6027;&#x548C;&#x7B80;&#x6D01;&#x5EA6;&#x3002;&#x6B63;&#x597D;&#x6700;&#x8FD1;&#x770B;&#x5230;&#x7F51;&#x4E0A;&#x4E00;&#x7BC7;&#x5F88;&#x597D;&#x7684;&#x5BF9;JavaScript&#x4E2D;&#x590D;&#x6742;&#x5224;&#x65AD;&#x7684;&#x5206;&#x6790;&#x6587;&#x7AE0;&#xFF0C;&#x8FD9;&#x91CC;&#x6574;&#x7406;&#x4E00;&#x4E0B;&#x5206;&#x4EAB;&#x7ED9;&#x5927;&#x5BB6;&#xFF0C;&#x5E0C;&#x671B;&#x80FD;&#x5BF9;&#x5404;&#x4F4D;&#x6709;&#x6240;&#x5E2E;&#x52A9;&#x3002;</p>
<p>&#x6211;&#x5C31;&#x662F;&#x4E00;&#x76F4;&#x7528;<strong>if-else</strong>&#xFF0C;&#x5927;&#x54ED;&#xFF0C;&#x975E;&#x5E38;&#x5927;&#x54ED;&#x3002;&#x770B;&#x6765;&#x8981;&#x7ECF;&#x5E38;&#x7814;&#x7A76;&#x600E;&#x4E48;&#x5904;&#x7406;&#x4EE3;&#x7801;&#x54AF;</p>
</blockquote>
<h4 id="if-else-&#x4E3E;&#x4F8B;&#x4E00;&#x5143;&#x5224;&#x65AD;"><a name="if-else-&#x4E3E;&#x4F8B;&#x4E00;&#x5143;&#x5224;&#x65AD;" class="anchor-navigation-ex-anchor" href="#if-else-&#x4E3E;&#x4F8B;&#x4E00;&#x5143;&#x5224;&#x65AD;"><i class="fa fa-link" aria-hidden="true"></i></a>if else &#x4E3E;&#x4F8B;(&#x4E00;&#x5143;&#x5224;&#x65AD;)</h4>
<pre><code class="lang-javascript"><span class="hljs-comment">/**
 * &#x6309;&#x94AE;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;
 * @param {number} status &#x6D3B;&#x52A8;&#x72B6;&#x6001;&#xFF1A;1 &#x5F00;&#x56E2;&#x8FDB;&#x884C;&#x4E2D; 2 &#x5F00;&#x56E2;&#x5931;&#x8D25; 3 &#x5546;&#x54C1;&#x552E;&#x7F44; 4 &#x5F00;&#x56E2;&#x6210;&#x529F; 5 &#x7CFB;&#x7EDF;&#x53D6;&#x6D88;
 */</span>
<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">status</span>)=&gt;</span>{
  <span class="hljs-keyword">if</span>(status == <span class="hljs-number">1</span>){
    sendLog(<span class="hljs-string">&apos;processing&apos;</span>)
    jumpTo(<span class="hljs-string">&apos;IndexPage&apos;</span>)
  }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">2</span>){
    sendLog(<span class="hljs-string">&apos;fail&apos;</span>)
    jumpTo(<span class="hljs-string">&apos;FailPage&apos;</span>)
  }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">3</span>){
    sendLog(<span class="hljs-string">&apos;fail&apos;</span>)
    jumpTo(<span class="hljs-string">&apos;FailPage&apos;</span>)
  }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">4</span>){
    sendLog(<span class="hljs-string">&apos;success&apos;</span>)
    jumpTo(<span class="hljs-string">&apos;SuccessPage&apos;</span>)
  }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">5</span>){
    sendLog(<span class="hljs-string">&apos;cancel&apos;</span>)
    jumpTo(<span class="hljs-string">&apos;CancelPage&apos;</span>)
  }<span class="hljs-keyword">else</span> {
    sendLog(<span class="hljs-string">&apos;other&apos;</span>)
    jumpTo(<span class="hljs-string">&apos;Index&apos;</span>)
  }
}
</code></pre>
<p> &#x901A;&#x8FC7;&#x4EE3;&#x7801;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#x8FD9;&#x4E2A;&#x6309;&#x94AE;&#x7684;&#x70B9;&#x51FB;&#x903B;&#x8F91;&#xFF1A;&#x6839;&#x636E;&#x4E0D;&#x540C;status&#x505A;&#x4E24;&#x4EF6;&#x4E8B;&#x60C5;&#xFF0C;sendLog&#x548C;&#x8DF3;&#x8F6C;&#x5230;&#x5BF9;&#x5E94;&#x9875;&#x9762;&#xFF0C;&#x5927;&#x5BB6;&#x53EF;&#x4EE5;&#x5F88;&#x8F7B;&#x6613;&#x7684;&#x63D0;&#x51FA;&#x8FD9;&#x6BB5;&#x4EE3;&#x7801;&#x7684;&#x6539;&#x5199;&#x65B9;&#x6848;&#xFF0C;switch&#x51FA;&#x573A;&#xFF1A; </p>
<blockquote>
<p>&#x73B0;&#x5728;&#x672C;&#x4EBA;&#x7528;&#x7684;&#x6BD4;&#x8F83;&#x591A;&#x7684;&#x5C31;&#x662F;switch&#xFF0C;&#x53D1;&#x73B0;&#x8FD8;&#x6BD4;&#x8F83;&#x597D;&#x7528;&#xFF0C;&#x54C8;&#x54C8;&#x54C8;&#x54C8;</p>
</blockquote>
<h4 id="switch&#x4EE3;&#x66FF;"><a name="switch&#x4EE3;&#x66FF;" class="anchor-navigation-ex-anchor" href="#switch&#x4EE3;&#x66FF;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>switch&#x4EE3;&#x66FF;</strong></h4>
<pre><code class="lang-javascript"><span class="hljs-comment">/**
 * &#x6309;&#x94AE;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;
 * @param {number} status &#x6D3B;&#x52A8;&#x72B6;&#x6001;&#xFF1A;1 &#x5F00;&#x56E2;&#x8FDB;&#x884C;&#x4E2D; 2 &#x5F00;&#x56E2;&#x5931;&#x8D25; 3 &#x5546;&#x54C1;&#x552E;&#x7F44; 4 &#x5F00;&#x56E2;&#x6210;&#x529F; 5 &#x7CFB;&#x7EDF;&#x53D6;&#x6D88;
 */</span>
<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">status</span>)=&gt;</span>{
  <span class="hljs-keyword">switch</span> (status){
    <span class="hljs-keyword">case</span> <span class="hljs-number">1</span>:
      sendLog(<span class="hljs-string">&apos;processing&apos;</span>)
      jumpTo(<span class="hljs-string">&apos;IndexPage&apos;</span>)
      <span class="hljs-keyword">break</span>
    <span class="hljs-keyword">case</span> <span class="hljs-number">2</span>:
    <span class="hljs-keyword">case</span> <span class="hljs-number">3</span>:
      sendLog(<span class="hljs-string">&apos;fail&apos;</span>)
      jumpTo(<span class="hljs-string">&apos;FailPage&apos;</span>)
      <span class="hljs-keyword">break</span>  
    <span class="hljs-keyword">case</span> <span class="hljs-number">4</span>:
      sendLog(<span class="hljs-string">&apos;success&apos;</span>)
      jumpTo(<span class="hljs-string">&apos;SuccessPage&apos;</span>)
      <span class="hljs-keyword">break</span>
    <span class="hljs-keyword">case</span> <span class="hljs-number">5</span>:
      sendLog(<span class="hljs-string">&apos;cancel&apos;</span>)
      jumpTo(<span class="hljs-string">&apos;CancelPage&apos;</span>)
      <span class="hljs-keyword">break</span>
    <span class="hljs-keyword">default</span>:
      sendLog(<span class="hljs-string">&apos;other&apos;</span>)
      jumpTo(<span class="hljs-string">&apos;Index&apos;</span>)
      <span class="hljs-keyword">break</span>
  }
}
</code></pre>
<blockquote>
<p>&#x542C;&#x8BF4;&#x8FD8;&#x6709;&#x66F4;&#x7B80;&#x5355;&#x7684;&#x5199;&#x6CD5;&#xFF0C;&#x7528;&#x7684;&#x6BD4;&#x8F83;&#x5C11;&#xFF0C;&#x6765;&#x6765;&#xFF0C;&#x6211;&#x4EEC;&#x4E00;&#x8D77;&#x770B;&#x770B;</p>
</blockquote>
<h4 id="&#x5BF9;&#x8C61;&#x6A21;&#x5F0F;&#x7B80;&#x5199;"><a name="&#x5BF9;&#x8C61;&#x6A21;&#x5F0F;&#x7B80;&#x5199;" class="anchor-navigation-ex-anchor" href="#&#x5BF9;&#x8C61;&#x6A21;&#x5F0F;&#x7B80;&#x5199;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>&#x5BF9;&#x8C61;&#x6A21;&#x5F0F;&#x7B80;&#x5199;</strong></h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = {
  <span class="hljs-string">&apos;1&apos;</span>: [<span class="hljs-string">&apos;processing&apos;</span>,<span class="hljs-string">&apos;IndexPage&apos;</span>],
  <span class="hljs-string">&apos;2&apos;</span>: [<span class="hljs-string">&apos;fail&apos;</span>,<span class="hljs-string">&apos;FailPage&apos;</span>],
  <span class="hljs-string">&apos;3&apos;</span>: [<span class="hljs-string">&apos;fail&apos;</span>,<span class="hljs-string">&apos;FailPage&apos;</span>],
  <span class="hljs-string">&apos;4&apos;</span>: [<span class="hljs-string">&apos;success&apos;</span>,<span class="hljs-string">&apos;SuccessPage&apos;</span>],
  <span class="hljs-string">&apos;5&apos;</span>: [<span class="hljs-string">&apos;cancel&apos;</span>,<span class="hljs-string">&apos;CancelPage&apos;</span>],
  <span class="hljs-string">&apos;default&apos;</span>: [<span class="hljs-string">&apos;other&apos;</span>,<span class="hljs-string">&apos;Index&apos;</span>],
}
<span class="hljs-comment">/**
 * &#x6309;&#x94AE;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;
 * @param {number} status &#x6D3B;&#x52A8;&#x72B6;&#x6001;&#xFF1A;1&#x5F00;&#x56E2;&#x8FDB;&#x884C;&#x4E2D; 2&#x5F00;&#x56E2;&#x5931;&#x8D25; 3 &#x5546;&#x54C1;&#x552E;&#x7F44; 4 &#x5F00;&#x56E2;&#x6210;&#x529F; 5 &#x7CFB;&#x7EDF;&#x53D6;&#x6D88;
 */</span>
<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = actions[status] || actions[<span class="hljs-string">&apos;default&apos;</span>],
      logName = action[<span class="hljs-number">0</span>],
      pageName = action[<span class="hljs-number">1</span>]
  sendLog(logName)
  jumpTo(pageName)
}
</code></pre>
<p>&#x4E0A;&#x9762;&#x4EE3;&#x7801;&#x786E;&#x5B9E;&#x770B;&#x8D77;&#x6765;&#x66F4;&#x6E05;&#x723D;&#x4E86;&#xFF0C;&#x8FD9;&#x79CD;&#x65B9;&#x6CD5;&#x7684;&#x806A;&#x660E;&#x4E4B;&#x5904;&#x5728;&#x4E8E;&#xFF1A;&#x5C06;&#x5224;&#x65AD;&#x6761;&#x4EF6;&#x4F5C;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x540D;&#xFF0C;&#x5C06;&#x5904;&#x7406;&#x903B;&#x8F91;&#x4F5C;&#x4E3A;&#x5BF9;&#x8C61;&#x7684;&#x5C5E;&#x6027;&#x503C;&#xFF0C;&#x5728;&#x6309;&#x94AE;&#x70B9;&#x51FB;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x901A;&#x8FC7;&#x5BF9;&#x8C61;&#x5C5E;&#x6027;&#x67E5;&#x627E;&#x7684;&#x65B9;&#x5F0F;&#x6765;&#x8FDB;&#x884C;&#x903B;&#x8F91;&#x5224;&#x65AD;&#xFF0C;&#x8FD9;&#x79CD;&#x5199;&#x6CD5;&#x7279;&#x522B;&#x9002;&#x5408;&#x4E00;&#x5143;&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x7684;&#x60C5;&#x51B5;&#x3002;&#x8FD8;&#x6709;es6&#x91CC;&#x9762;&#x7684;Map&#x5BF9;&#x8C61;&#x7B80;&#x5199;:</p>
<blockquote>
<p>&#x4E0B;&#x9762;&#x5C31;&#x662F;map&#xFF0C;&#x8FD9;&#x4E2A;&#x7528;&#x7684;&#x6BD4;&#x8F83;&#x591A;&#xFF0C;&#x4E0D;&#x8FC7;&#x6B63;&#x5E38;&#x90FD;&#x4E0D;&#x662F;&#x8FD9;&#x6837;&#x7528;&#xFF0C;&#x6DA8;&#x77E5;&#x8BC6;&#x4E86;</p>
<p>new Map() &#x8FD9;&#x4E2A;&#x529F;&#x80FD;&#x8981;&#x597D;&#x597D;&#x5B66;&#x5B66;&#xFF0C;&#x7406;&#x89E3;&#x4E00;&#x4E0B;</p>
</blockquote>
<h4 id="map"><a name="map" class="anchor-navigation-ex-anchor" href="#map"><i class="fa fa-link" aria-hidden="true"></i></a><strong>Map</strong></h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([
  [<span class="hljs-number">1</span>, [<span class="hljs-string">&apos;processing&apos;</span>,<span class="hljs-string">&apos;IndexPage&apos;</span>]],
  [<span class="hljs-number">2</span>, [<span class="hljs-string">&apos;fail&apos;</span>,<span class="hljs-string">&apos;FailPage&apos;</span>]],
  [<span class="hljs-number">3</span>, [<span class="hljs-string">&apos;fail&apos;</span>,<span class="hljs-string">&apos;FailPage&apos;</span>]],
  [<span class="hljs-number">4</span>, [<span class="hljs-string">&apos;success&apos;</span>,<span class="hljs-string">&apos;SuccessPage&apos;</span>]],
  [<span class="hljs-number">5</span>, [<span class="hljs-string">&apos;cancel&apos;</span>,<span class="hljs-string">&apos;CancelPage&apos;</span>]],
  [<span class="hljs-string">&apos;default&apos;</span>, [<span class="hljs-string">&apos;other&apos;</span>,<span class="hljs-string">&apos;Index&apos;</span>]]
])
<span class="hljs-comment">/**
 * &#x6309;&#x94AE;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;
 * @param {number} status &#x6D3B;&#x52A8;&#x72B6;&#x6001;&#xFF1A;1 &#x5F00;&#x56E2;&#x8FDB;&#x884C;&#x4E2D; 2 &#x5F00;&#x56E2;&#x5931;&#x8D25; 3 &#x5546;&#x54C1;&#x552E;&#x7F44; 4 &#x5F00;&#x56E2;&#x6210;&#x529F; 5 &#x7CFB;&#x7EDF;&#x53D6;&#x6D88;
 */</span>
<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = actions.get(status) || actions.get(<span class="hljs-string">&apos;default&apos;</span>)
  sendLog(action[<span class="hljs-number">0</span>])
  jumpTo(action[<span class="hljs-number">1</span>])
}
</code></pre>
<p>&#x8FD9;&#x6837;&#x5199;&#x7528;&#x5230;&#x4E86;es6&#x91CC;&#x7684;Map&#x5BF9;&#x8C61;&#xFF0C;&#x662F;&#x4E0D;&#x662F;&#x66F4;&#x723D;&#x4E86;&#xFF1F;Map&#x5BF9;&#x8C61;&#x548C;Object&#x5BF9;&#x8C61;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;&#x5462;&#xFF1F;</p>
<p>1.&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x901A;&#x5E38;&#x90FD;&#x6709;&#x81EA;&#x5DF1;&#x7684;&#x539F;&#x578B;&#xFF0C;&#x6240;&#x4EE5;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x603B;&#x6709;&#x4E00;&#x4E2A;&quot;prototype&quot;&#x952E;&#x3002;
 2.&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x7684;&#x952E;&#x53EA;&#x80FD;&#x662F;&#x5B57;&#x7B26;&#x4E32;&#x6216;&#x8005;Symbols&#xFF0C;&#x4F46;&#x4E00;&#x4E2A;Map&#x7684;&#x952E;&#x53EF;&#x4EE5;&#x662F;&#x4EFB;&#x610F;&#x503C;&#x3002;
 3.&#x4F60;&#x53EF;&#x4EE5;&#x901A;&#x8FC7;size&#x5C5E;&#x6027;&#x5F88;&#x5BB9;&#x6613;&#x5730;&#x5F97;&#x5230;&#x4E00;&#x4E2A;Map&#x7684;&#x952E;&#x503C;&#x5BF9;&#x4E2A;&#x6570;&#xFF0C;&#x800C;&#x5BF9;&#x8C61;&#x7684;&#x952E;&#x503C;&#x5BF9;&#x4E2A;&#x6570;&#x53EA;&#x80FD;&#x624B;&#x52A8;&#x786E;&#x8BA4;&#x3002;</p>
<p>&#x6211;&#x4EEC;&#x9700;&#x8981;&#x628A;&#x95EE;&#x9898;&#x5347;&#x7EA7;&#x4E00;&#x4E0B;&#xFF0C;&#x4EE5;&#x524D;&#x6309;&#x94AE;&#x70B9;&#x51FB;&#x65F6;&#x5019;&#x53EA;&#x9700;&#x8981;&#x5224;&#x65AD;status&#xFF0C;&#x73B0;&#x5728;&#x8FD8;&#x9700;&#x8981;&#x5224;&#x65AD;&#x7528;&#x6237;&#x7684;&#x8EAB;&#x4EFD;&#xFF1A;</p>
<h4 id="if-else-&#x4E3E;&#x4F8B;&#x4E8C;&#x5143;&#x5224;&#x65AD;"><a name="if-else-&#x4E3E;&#x4F8B;&#x4E8C;&#x5143;&#x5224;&#x65AD;" class="anchor-navigation-ex-anchor" href="#if-else-&#x4E3E;&#x4F8B;&#x4E8C;&#x5143;&#x5224;&#x65AD;"><i class="fa fa-link" aria-hidden="true"></i></a>if else &#x4E3E;&#x4F8B;(&#x4E8C;&#x5143;&#x5224;&#x65AD;)</h4>
<pre><code class="lang-javascript"><span class="hljs-comment">/**
 * &#x6309;&#x94AE;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;
 * @param {number} status &#x6D3B;&#x52A8;&#x72B6;&#x6001;&#xFF1A;1&#x5F00;&#x56E2;&#x8FDB;&#x884C;&#x4E2D; 2&#x5F00;&#x56E2;&#x5931;&#x8D25; 3 &#x5F00;&#x56E2;&#x6210;&#x529F; 4 &#x5546;&#x54C1;&#x552E;&#x7F44; 5 &#x6709;&#x5E93;&#x5B58;&#x672A;&#x5F00;&#x56E2;
 * @param {string} identity &#x8EAB;&#x4EFD;&#x6807;&#x8BC6;&#xFF1A;guest&#x5BA2;&#x6001; master&#x4E3B;&#x6001;
 */</span>
<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">status,identity</span>)=&gt;</span>{
  <span class="hljs-keyword">if</span>(identity == <span class="hljs-string">&apos;guest&apos;</span>){
    <span class="hljs-keyword">if</span>(status == <span class="hljs-number">1</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">2</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">3</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">4</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">5</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> {
      <span class="hljs-comment">//do sth</span>
    }
  }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(identity == <span class="hljs-string">&apos;master&apos;</span>) {
    <span class="hljs-keyword">if</span>(status == <span class="hljs-number">1</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">2</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">3</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">4</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> <span class="hljs-keyword">if</span>(status == <span class="hljs-number">5</span>){
      <span class="hljs-comment">//do sth</span>
    }<span class="hljs-keyword">else</span> {
      <span class="hljs-comment">//do sth</span>
    }
  }
}
</code></pre>
<p> &#x4ECE;&#x4E0A;&#x9762;&#x7684;&#x4F8B;&#x5B50;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x770B;&#x5230;&#xFF0C;&#x5F53;&#x4F60;&#x7684;&#x903B;&#x8F91;&#x5347;&#x7EA7;&#x4E3A;&#x4E8C;&#x5143;&#x5224;&#x65AD;&#x65F6;&#xFF0C;&#x4F60;&#x7684;&#x5224;&#x65AD;&#x91CF;&#x4F1A;&#x52A0;&#x500D;&#xFF0C;&#x4F60;&#x7684;&#x4EE3;&#x7801;&#x91CF;&#x4E5F;&#x4F1A;&#x52A0;&#x500D;&#xFF0C;&#x8FD9;&#x65F6;&#x600E;&#x4E48;&#x5199;&#x66F4;&#x6E05;&#x723D;&#x5462;&#xFF1F; </p>
<blockquote>
<p>&#x6211;&#x80FD;&#x8BF4;&#x5F88;&#x4E0D;&#x723D;&#x5427;&#xFF0C;&#x6551;&#x65B0;&#x89E3;&#xFF01;&#xFF01;&#xFF01;&#xFF01;</p>
</blockquote>
<h4 id="map&#x5B9E;&#x73B0;"><a name="map&#x5B9E;&#x73B0;" class="anchor-navigation-ex-anchor" href="#map&#x5B9E;&#x73B0;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>Map&#x5B9E;&#x73B0;</strong></h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([
  [<span class="hljs-string">&apos;guest_1&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;guest_2&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;guest_3&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;guest_4&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;guest_5&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;master_1&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;master_2&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;master_3&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;master_4&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;master_5&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [<span class="hljs-string">&apos;default&apos;</span>, ()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
])

<span class="hljs-comment">/**
 * &#x6309;&#x94AE;&#x70B9;&#x51FB;&#x4E8B;&#x4EF6;
 * @param {string} identity &#x8EAB;&#x4EFD;&#x6807;&#x8BC6;&#xFF1A;guest&#x5BA2;&#x6001; master&#x4E3B;&#x6001;
 * @param {number} status &#x6D3B;&#x52A8;&#x72B6;&#x6001;&#xFF1A;1 &#x5F00;&#x56E2;&#x8FDB;&#x884C;&#x4E2D; 2 &#x5F00;&#x56E2;&#x5931;&#x8D25; 3 &#x5F00;&#x56E2;&#x6210;&#x529F; 4 &#x5546;&#x54C1;&#x552E;&#x7F44; 5 &#x6709;&#x5E93;&#x5B58;&#x672A;&#x5F00;&#x56E2;
 */</span>
<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">identity,status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = actions.get(<span class="hljs-string">`<span class="hljs-subst">${identity}</span>_<span class="hljs-subst">${status}</span>`</span>) || actions.get(<span class="hljs-string">&apos;default&apos;</span>)
  action.call(<span class="hljs-keyword">this</span>)
}
</code></pre>
<p> &#x4E0A;&#x8FF0;&#x4EE3;&#x7801;&#x6838;&#x5FC3;&#x903B;&#x8F91;&#x662F;&#xFF1A;&#x628A;&#x4E24;&#x4E2A;&#x6761;&#x4EF6;&#x62FC;&#x63A5;&#x6210;&#x5B57;&#x7B26;&#x4E32;&#xFF0C;&#x5E76;&#x901A;&#x8FC7;&#x4EE5;&#x6761;&#x4EF6;&#x62FC;&#x63A5;&#x5B57;&#x7B26;&#x4E32;&#x4F5C;&#x4E3A;&#x952E;&#xFF0C;&#x4EE5;&#x5904;&#x7406;&#x51FD;&#x6570;&#x4F5C;&#x4E3A;&#x503C;&#x7684;Map&#x5BF9;&#x8C61;&#x8FDB;&#x884C;&#x67E5;&#x627E;&#x5E76;&#x6267;&#x884C;&#xFF0C;&#x8FD9;&#x79CD;&#x5199;&#x6CD5;&#x5728;&#x591A;&#x5143;&#x6761;&#x4EF6;&#x5224;&#x65AD;&#x65F6;&#x5019;&#x5C24;&#x5176;&#x597D;&#x7528;&#x3002; </p>
<p> &#x5F53;&#x7136;&#x4E0A;&#x8FF0;&#x4EE3;&#x7801;&#x5982;&#x679C;&#x7528;Object&#x5BF9;&#x8C61;&#x6765;&#x5B9E;&#x73B0;&#x4E5F;&#x662F;&#x7C7B;&#x4F3C;&#x7684;&#xFF1A; </p>
<h4 id="object&#x5B9E;&#x73B0;"><a name="object&#x5B9E;&#x73B0;" class="anchor-navigation-ex-anchor" href="#object&#x5B9E;&#x73B0;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>Object&#x5B9E;&#x73B0;</strong></h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = {
  <span class="hljs-string">&apos;guest_1&apos;</span>:<span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>},
  <span class="hljs-string">&apos;guest_2&apos;</span>:<span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>},
  <span class="hljs-comment">//....</span>
}

<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">identity,status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = actions[<span class="hljs-string">`<span class="hljs-subst">${identity}</span>_<span class="hljs-subst">${status}</span>`</span>] || actions[<span class="hljs-string">&apos;default&apos;</span>]
  action.call(<span class="hljs-keyword">this</span>)
}
</code></pre>
<p> &#x5982;&#x679C;&#x6709;&#x4E9B;&#x540C;&#x5B66;&#x89C9;&#x5F97;&#x628A;&#x67E5;&#x8BE2;&#x6761;&#x4EF6;&#x62FC;&#x6210;&#x5B57;&#x7B26;&#x4E32;&#x6709;&#x70B9;&#x522B;&#x626D;&#xFF0C;&#x90A3;&#x8FD8;&#x6709;&#x4E00;&#x79CD;&#x65B9;&#x6848;&#xFF0C;&#x5C31;&#x662F;&#x7528;Map&#x5BF9;&#x8C61;&#xFF0C;&#x4EE5;Object&#x5BF9;&#x8C61;&#x4F5C;&#x4E3A;key&#xFF1A; </p>
<h4 id="map-&#x89C4;&#x6574;&#x5199;&#x6CD5;"><a name="map-&#x89C4;&#x6574;&#x5199;&#x6CD5;" class="anchor-navigation-ex-anchor" href="#map-&#x89C4;&#x6574;&#x5199;&#x6CD5;"><i class="fa fa-link" aria-hidden="true"></i></a><strong>Map &#x89C4;&#x6574;&#x5199;&#x6CD5;</strong></h4>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([
  [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">1</span>},()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">2</span>},()=&gt;{<span class="hljs-comment">/*do sth*/</span>}],
  <span class="hljs-comment">//...</span>
])

<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">identity,status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = [...actions].filter(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>(key.identity == identity &amp;&amp; key.status == status))
  action.forEach(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>value.call(<span class="hljs-keyword">this</span>))
}
</code></pre>
<p>&#x662F;&#x4E0D;&#x662F;&#x53C8;&#x9AD8;&#x7EA7;&#x4E86;&#x4E00;&#x70B9;&#x70B9;&#xFF1F;</p>
<p>&#x8FD9;&#x91CC;&#x4E5F;&#x770B;&#x51FA;&#x6765;Map&#x4E0E;Object&#x7684;&#x533A;&#x522B;&#xFF0C;Map&#x53EF;&#x4EE5;&#x7528;&#x4EFB;&#x4F55;&#x7C7B;&#x578B;&#x7684;&#x6570;&#x636E;&#x4F5C;&#x4E3A;key&#x3002;</p>
<h4 id="&#x63A2;&#x8BA8;&#x4E0B;&#x5404;&#x79CD;&#x60C5;&#x51B5;"><a name="&#x63A2;&#x8BA8;&#x4E0B;&#x5404;&#x79CD;&#x60C5;&#x51B5;" class="anchor-navigation-ex-anchor" href="#&#x63A2;&#x8BA8;&#x4E0B;&#x5404;&#x79CD;&#x60C5;&#x51B5;"><i class="fa fa-link" aria-hidden="true"></i></a>&#x63A2;&#x8BA8;&#x4E0B;&#x5404;&#x79CD;&#x60C5;&#x51B5;</h4>
<p> &#x6211;&#x4EEC;&#x73B0;&#x5728;&#x518D;&#x5C06;&#x96BE;&#x5EA6;&#x5347;&#x7EA7;&#x4E00;&#x70B9;&#x70B9;&#xFF0C;&#x5047;&#x5982;guest&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;status1-4&#x7684;&#x5904;&#x7406;&#x903B;&#x8F91;&#x90FD;&#x4E00;&#x6837;&#x600E;&#x4E48;&#x529E;&#xFF0C;&#x6700;&#x5DEE;&#x7684;&#x60C5;&#x51B5;&#x662F;&#x8FD9;&#x6837;&#xFF1A; </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([
  [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">1</span>},()=&gt;{<span class="hljs-comment">/* functionA */</span>}],
  [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">2</span>},()=&gt;{<span class="hljs-comment">/* functionA */</span>}],
  [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">3</span>},()=&gt;{<span class="hljs-comment">/* functionA */</span>}],
  [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">4</span>},()=&gt;{<span class="hljs-comment">/* functionA */</span>}],
  [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">5</span>},()=&gt;{<span class="hljs-comment">/* functionB */</span>}],
  <span class="hljs-comment">//...</span>
])
</code></pre>
<p> &#x597D;&#x4E00;&#x70B9;&#x7684;&#x5199;&#x6CD5;&#x662F;&#x5C06;&#x5904;&#x7406;&#x903B;&#x8F91;&#x51FD;&#x6570;&#x8FDB;&#x884C;&#x7F13;&#x5B58;&#xFF1A; </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{
  <span class="hljs-keyword">const</span> functionA = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>}
  <span class="hljs-keyword">const</span> functionB = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>}
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([
    [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">1</span>},functionA],
    [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">2</span>},functionA],
    [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">3</span>},functionA],
    [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">4</span>},functionA],
    [{<span class="hljs-attr">identity</span>:<span class="hljs-string">&apos;guest&apos;</span>,<span class="hljs-attr">status</span>:<span class="hljs-number">5</span>},functionB],
    <span class="hljs-comment">//...</span>
  ])
}

<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">identity,status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = [...actions()].filter(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>(key.identity == identity &amp;&amp; key.status == status))
  action.forEach(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>value.call(<span class="hljs-keyword">this</span>))
}
</code></pre>
<p>&#x8FD9;&#x6837;&#x5199;&#x5DF2;&#x7ECF;&#x80FD;&#x6EE1;&#x8DB3;&#x65E5;&#x5E38;&#x9700;&#x6C42;&#x4E86;&#xFF0C;&#x4F46;&#x8BA4;&#x771F;&#x4E00;&#x70B9;&#x8BB2;&#xFF0C;&#x4E0A;&#x9762;&#x91CD;&#x5199;&#x4E86;4&#x6B21;functionA&#x8FD8;&#x662F;&#x6709;&#x70B9;&#x4E0D;&#x723D;&#xFF0C;&#x5047;&#x5982;&#x5224;&#x65AD;&#x6761;&#x4EF6;&#x53D8;&#x5F97;&#x7279;&#x522B;&#x590D;&#x6742;&#xFF0C;&#x6BD4;&#x5982;identity&#x6709;3&#x79CD;&#x72B6;&#x6001;&#xFF0C;status&#x6709;10&#x79CD;&#x72B6;&#x6001;&#xFF0C;&#x90A3;&#x4F60;&#x9700;&#x8981;&#x5B9A;&#x4E49;30&#x6761;&#x5904;&#x7406;&#x903B;&#x8F91;&#xFF0C;&#x800C;&#x5F80;&#x5F80;&#x8FD9;&#x4E9B;&#x903B;&#x8F91;&#x91CC;&#x9762;&#x5F88;&#x591A;&#x90FD;&#x662F;&#x76F8;&#x540C;&#x7684;&#xFF0C;&#x90A3;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x5B9E;&#x73B0;:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{
  <span class="hljs-keyword">const</span> functionA = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>}
  <span class="hljs-keyword">const</span> functionB = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>}
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([
    [<span class="hljs-regexp">/^guest_[1-4]$/</span>,functionA],
    [<span class="hljs-regexp">/^guest_5$/</span>,functionB],
    <span class="hljs-comment">//...</span>
  ])
}

<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">identity,status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = [...actions()].filter(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>(key.test(<span class="hljs-string">`<span class="hljs-subst">${identity}</span>_<span class="hljs-subst">${status}</span>`</span>)))
  action.forEach(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>value.call(<span class="hljs-keyword">this</span>))
}
</code></pre>
<p> &#x8FD9;&#x91CC;Map&#x7684;&#x4F18;&#x52BF;&#x66F4;&#x52A0;&#x51F8;&#x663E;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x6B63;&#x5219;&#x7C7B;&#x578B;&#x4F5C;&#x4E3A;key&#x4E86;&#xFF0C;&#x8FD9;&#x6837;&#x5C31;&#x6709;&#x4E86;&#x65E0;&#x9650;&#x53EF;&#x80FD;&#xFF0C;&#x5047;&#x5982;&#x9700;&#x6C42;&#x53D8;&#x6210;&#xFF0C;&#x51E1;&#x662F;guest&#x60C5;&#x51B5;&#x90FD;&#x8981;&#x53D1;&#x9001;&#x4E00;&#x4E2A;&#x65E5;&#x5FD7;&#x57CB;&#x70B9;&#xFF0C;&#x4E0D;&#x540C;status&#x60C5;&#x51B5;&#x4E5F;&#x9700;&#x8981;&#x5355;&#x72EC;&#x7684;&#x903B;&#x8F91;&#x5904;&#x7406;&#xFF0C;&#x90A3;&#x6211;&#x4EEC;&#x53EF;&#x4EE5;&#x8FD9;&#x6837;&#x5199;: </p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> actions = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{
  <span class="hljs-keyword">const</span> functionA = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>}
  <span class="hljs-keyword">const</span> functionB = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*do sth*/</span>}
  <span class="hljs-keyword">const</span> functionC = <span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{<span class="hljs-comment">/*send log*/</span>}
  <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Map</span>([
    [<span class="hljs-regexp">/^guest_[1-4]$/</span>,functionA],
    [<span class="hljs-regexp">/^guest_5$/</span>,functionB],
    [<span class="hljs-regexp">/^guest_.*$/</span>,functionC],
    <span class="hljs-comment">//...</span>
  ])
}

<span class="hljs-keyword">const</span> onButtonClick = <span class="hljs-function">(<span class="hljs-params">identity,status</span>)=&gt;</span>{
  <span class="hljs-keyword">let</span> action = [...actions()].filter(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>(key.test(<span class="hljs-string">`<span class="hljs-subst">${identity}</span>_<span class="hljs-subst">${status}</span>`</span>)))
  action.forEach(<span class="hljs-function">(<span class="hljs-params">[key,value]</span>)=&gt;</span>value.call(<span class="hljs-keyword">this</span>))
}
</code></pre>
<p> &#x4E5F;&#x5C31;&#x662F;&#x8BF4;&#x5229;&#x7528;&#x6570;&#x7EC4;&#x5FAA;&#x73AF;&#x7684;&#x7279;&#x6027;&#xFF0C;&#x7B26;&#x5408;&#x6B63;&#x5219;&#x6761;&#x4EF6;&#x7684;&#x903B;&#x8F91;&#x90FD;&#x4F1A;&#x88AB;&#x6267;&#x884C;&#xFF0C;&#x90A3;&#x5C31;&#x53EF;&#x4EE5;&#x540C;&#x65F6;&#x6267;&#x884C;&#x516C;&#x5171;&#x903B;&#x8F91;&#x548C;&#x5355;&#x72EC;&#x903B;&#x8F91;&#xFF0C;&#x56E0;&#x4E3A;&#x6B63;&#x5219;&#x7684;&#x5B58;&#x5728;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x6253;&#x5F00;&#x60F3;&#x8C61;&#x529B;&#x89E3;&#x9501;&#x66F4;&#x591A;&#x7684;&#x73A9;&#x6CD5;&#xFF0C;&#x672C;&#x6587;&#x5C31;&#x4E0D;&#x8D58;&#x8FF0;&#x4E86;&#x3002;  </p>
<footer class="page-footer"><span class="copyright">Copyright &#xA9; zhengyuliang all right reserved&#xFF0C;powered by Gitbook</span><span class="footer-modification">&#x8BE5;&#x6587;&#x4EF6;&#x7F16;&#x5199;&#x65F6;&#x95F4;&#xFF1A;
2019-11-20 10:15:43
</span></footer></body></html>
                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="JavaScript数组求并集，交集和差集.html" class="navigation navigation-prev " aria-label="Previous page: JavaScript数组求并集，交集和差集">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="axios知识点.html" class="navigation navigation-next " aria-label="Next page: Axios知识点">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"JavaScript的优雅写法","level":"4.9","depth":1,"next":{"title":"Axios知识点","level":"4.10","depth":1,"path":"javaScript/axios知识点.md","ref":"javaScript/axios知识点.md","articles":[]},"previous":{"title":"JavaScript数组求并集，交集和差集","level":"4.8","depth":1,"path":"javaScript/JavaScript数组求并集，交集和差集.md","ref":"javaScript/JavaScript数组求并集，交集和差集.md","articles":[]},"dir":"ltr"},"config":{"plugins":["sectionx","splitter","tbfed-pagefooter","toggle-chapters","theme-comscore","-lunr","-search","search-plus","donate","anchor-navigation-ex","expandable-chapters","chapter-fold","expandable-chapters-small","livereload"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"tbfed-pagefooter":{"copyright":"Copyright &copy zhengyuliang","modify_label":"该文件编写时间：","modify_format":"YYYY-MM-DD HH:mm:ss"},"chapter-fold":{},"pluginsConfig":{"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"}},"livereload":{},"splitter":{},"donate":{"title":"","button":"赏","wechat":"https://gitee.com/htzyl/img_bed/raw/master/pay/weixin-min.jpg","alipay":"https://gitee.com/htzyl/img_bed/raw/master/pay/alipay-min.jpg","wechatText":"微信打赏","alipayText":"支付宝打赏"},"fontsettings":{"theme":"white","family":"sans","size":2},"sectionx":{"tag":"b"},"highlight":{},"anchor-navigation-ex":{"showLevel":true,"associatedWithSummary":true,"mode":"float","showGoTop":true,"printLog":false,"multipleH1":true,"float":{"floatIcon":"fa fa-navicon","showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""},"pageTop":{"showLevelIcon":false,"level1Icon":"","level2Icon":"","level3Icon":""}},"theme-comscore":{},"expandable-chapters-small":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{},"expandable-chapters":{},"search-plus":{}},"theme":"default","author":"zhengyuliang","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"记录技术文档内容","language":"zh-hans","gitbook":">=3.0.0","description":"记录Gitbook的配置和一些插件的使用","theme-default":{"showLevel":true}},"file":{"path":"javaScript/JavaScript的优雅写法.md","mtime":"2019-11-20T02:15:43.867Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2022-01-06T09:44:01.178Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sectionx/sectionx.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-splitter/splitter.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-plus/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-donate/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters-small/expandable-chapters-small.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-livereload/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

